/*
 * Copyright (C) 2017-2021
 * All rights reserved, Designed By
 * Copyright authorization contact 18814114118
 */
package com.shop.cereshop.app.dao.buyer;

import com.shop.cereshop.app.domain.buyer.BuyerSearchVO;
import com.shop.cereshop.commons.domain.buyer.CereBuyerSearch;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.common.Page;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface CereBuyerSearchDAO extends BaseMapper<CereBuyerSearch> {
    int deleteByPrimaryKey(Long searchId);

    int insertSelective(CereBuyerSearch record);

    CereBuyerSearch selectByPrimaryKey(Long searchId);

    int updateByPrimaryKeySelective(CereBuyerSearch record);

    int updateByPrimaryKey(CereBuyerSearch record);

    List<CereBuyerSearch> getHistory(@Param("buyerUserId") Long buyerUserId);


    List<CereBuyerSearch> getHistoryByPage(@Param("buyerUserId") Long buyerUserId, @Param("type") Integer type);

    // void delete(@Param("searchId") Long searchId);

    CereBuyerSearch findBySearch(@Param("search") String search,@Param("buyerUserId") Long buyerUserId,@Param("searchType") Integer searchType);

    void updateBuyerData(@Param("buyerUserId") Long buyerUserId,@Param("id") Long id);

    List<String> selectHotSearch();

    /**
     * 查询用户搜索记录（取最新10条）
     * @param buyerUserId 用户ID
     * @param searchType  搜索类型（1-商品,2-店铺,3-购物车）
     * @return 用户搜索记录
     */
    List<BuyerSearchVO> getUserSearchList(@Param("buyerUserId") Long buyerUserId, @Param("searchType") Integer searchType);

    /**
     * 查询用户搜索热门记录（取100条，相同频次时按搜索词排序，同一搜索词内，最新记录（ID大）在前）
     * @param buyerUserId 用户ID
     * @param searchType  搜索类型（1-商品,2-店铺,3-购物车）
     * @return 用户搜索记录
     */
    List<BuyerSearchVO> getUserHotSearch(@Param("buyerUserId") Long buyerUserId, @Param("searchType") Integer searchType);

    void deleteBuyerSearch(@Param("buyerUserId") Long buyerUserId, @Param("searchId") Long searchId);

    void deleteBuyerSearchBySearchType(@Param("buyerUserId") Long buyerUserId, @Param("searchType") Integer searchType);
}
